<?php


class Setting extends CI_Controller{
	//构造函数
	function __construct(){
		parent::__construct();	
		
		//测试后删除
		$this->load->library('ChromePhp');
		
		//载入user 模型
		$this -> load -> model('User');
		
		//实际函数
		if(!$this->session->userdata('user_id')){
			$this->load->helper('url');
			redirect('/Login');
		}
	}
	
	//首页
	public function  Index () {
		//$this-> load -> view('Home');
		echo '这是设置首页';
	}
	
	public function UserSetting () {
		$get_query = $this -> User -> getUserInfo();
		$this -> chromephp -> log($get_query->row());
		
		$data = array(
				'user_account' => $this->session->userdata('user_account'),
				'user_name' => $get_query -> row() -> user_name,
				'user_email' => $get_query -> row() -> user_email,
				'synchro' => $get_query -> row() -> synchro == 0 ? false : true ,
				);
		$this-> load -> view('setting_user',$data);
	}
	
	public function UserSettingUpdate () {
		$get_query = $this -> User -> setUserInfo($_POST['user_name'], $_POST['user_new_password'],  $_POST['user_email'], $_POST['user_email_password'], $svn = ($_POST['user_new_password'] == '' ? false : true) );
	}
}
